import { createRouter, createWebHistory } from 'vue-router'

import Login from '../views/login/index.vue'
import Home from '../views/home/index.vue'
import Layout from '../views/layout/index.vue'
import DataShow from '../views/layout/datashow/index.vue'
import Authority from '../views/layout/authority/index.vue'
import Good from '../views/layout/goods/index.vue'
import Permission from '../views/layout/authority/permission/index.vue'
import Role from '../views/layout/authority/role/index.vue'
import Users from '../views/layout/authority/user/index.vue'
import Brand from '../views/layout/goods/brand/index.vue'
import Property from '../views/layout/goods/property/index.vue'
import SPU from '../views/layout/goods/SPU/index.vue'
import SKU from '../views/layout/goods/SKU/index.vue'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/login',
            component: Login,
            name: 'login'
        },
        {
            path: '/layout',
            component: Layout,
            name: 'layout',
            children: [
                {
                    path: '/home',
                    component: Home,
                    name: 'home',
                    meta: {
                        title: '首页',
                        icon: 'House'
                    }
                },
                {
                    path: '/datashow',
                    component: DataShow,
                    name: 'datashow',
                    meta: {
                        title: '数据大屏',
                        icon: 'DataBoard'
                    }
                },
                {
                    path: '/authority',
                    component: Authority,
                    name: 'authority',
                    //重定向，返回时跳转到用户管理，避免空屏
                    redirect: '/authority/user',
                    meta: {
                        title: '权限管理',
                        icon: 'Lock'
                    },
                    children: [
                        {
                            path: '/authority/permission',
                            component: Permission,
                            meta: {
                                title: '菜单管理',
                                icon: 'Menu'
                            }
                        },
                        {
                            path: '/authority/role',
                            component: Role,
                            meta: {
                                title: '角色管理',
                                icon: 'UserFilled'
                            }
                        },
                        {
                            path: '/authority/user',
                            component: Users,
                            meta: {
                                title: '用户管理',
                                icon: 'User'
                            }
                        }
                    ]
                },
                {
                    path: '/goods',
                    component: Good,
                    name: 'goods',
                    //重定向，返回时跳转到品牌管理，避免空屏
                    redirect: '/goods/brand',
                    meta: {
                        title: '商品管理',
                        icon: 'Goods'
                    },
                    children: [
                        {
                            path: '/goods/brand',
                            component: Brand,
                            meta: {
                                title: '品牌管理',
                                icon: 'ShoppingCart'
                            }
                        },
                        {
                            path: '/goods/property',
                            component: Property,
                            meta: {
                                title: '属性管理',
                                icon: 'User'
                            }
                        },
                        {
                            path: '/goods/spu',
                            component: SPU,
                            meta: {
                                title: 'SPU管理',
                                icon: 'Menu'
                            }
                        },
                        {
                            path: '/goods/sku',
                            component: SKU,
                            meta: {
                                title: 'SKU管理',
                                icon: 'Menu'
                            }
                        }
                    ]
                }
            ]
        },
        {
            path: '/',
            redirect: '/login'
        }
    ],
    /*
    scrollBehavior() {
        return {
            left: 0,
            top: 0
        }
    }
    */
})

export default router;